package com.simulacra.model;

import com.simulacra.util.log.Logger;
/**
 * 
 *  Clase que se usa para determinar el tipo de evento que se genere
 *  
 */
public class RangeTable {
	private double eventRange[]= null;
	private double teamRange[] = null;
	public RangeTable (double[] axisX, double[] axisY) {
		setEventRange(axisX);
		setTeamRange(axisY);
		
	}
	public String getLocation (double axisX, double axisY) {

		return findYLocation(axisY)+ "-" + findXLocation(axisX);
		
	}
	private String findYLocation (double value) {
		double eventRange[] = getTeamRange() ;
		double accumulated= 0;

		int i= 0;// Logger.log(this, value+ " V.S. "+ accumulated);
		for ( i= 0; eventRange != null && i< eventRange.length ; i++) {
			accumulated += eventRange[i];
			
			if (value <= accumulated) {
				break; // returnValue= String.valueOf(i +1);
			}
			
		}
		return String.valueOf(i );
		
	}
	private String findXLocation (double value) {
		double eventRange[] = getEventRange() ;
		double accumulated= 0;
		String returnValue = "0";
		for (int i= 0; eventRange != null && i< eventRange.length ; i++) {
			accumulated += eventRange[i];
			if (value <= accumulated) {
				returnValue= String.valueOf(i +1);
				break;
			}
			
		}
		return returnValue;
	}
	private void setEventRange(double eventRange[]) {
		this.eventRange = eventRange;
	}
	private double[] getEventRange() {
		return eventRange;
	}
	public void setTeamRange(double teamRange[]) {
		this.teamRange = teamRange;
	}
	private double[] getTeamRange() {
		return teamRange;
	}
	public static void main (String [] main) {
		RangeTable table = null;
		table = new RangeTable(new double[]{0.2,0.1,0.1,0.3,0.3}, new double[]{0.7,0.3});
		Logger.log(null, "value :"+ table.getLocation(0.9, 0.1));
		table.getTeamRange();


	}
	

}
